{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "a0abdcf0-deb9-4055-9459-efb5eb1d0086",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 导入os整个模块\n",
    "# 模块：文件名\n",
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "ea1670dc-fce3-4276-a01f-0ee9a51fd57d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'c:\\\\Users\\\\JN-SH\\\\Desktop\\\\pythonBase\\\\11.module\\\\11.1.基础模块'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 模块.方法\n",
    "os.getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "3fca751b-1217-4ebd-bed1-58aafaa2e29e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'c:\\\\Users\\\\JN-SH\\\\Desktop\\\\pythonBase\\\\11.module\\\\11.1.基础模块'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 导入os模块的getcwd方法\n",
    "# getcwd不能有相同方法，会冲突\n",
    "from os import getcwd\n",
    "# 方法\n",
    "getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "1893951c-cd49-4cd8-a2e2-82cba74731e6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: numpy in c:\\users\\jn-sh\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (1.25.2)\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n",
      "[notice] A new release of pip is available: 23.1.2 -> 23.2.1\n",
      "[notice] To update, run: python.exe -m pip install --upgrade pip\n"
     ]
    }
   ],
   "source": [
    "!pip3.11 install numpy\n",
    "# 为导入模块指定别名\n",
    "import numpy as np\n",
    "# 导入模块所有函数,不建议使用，容易函数冲突\n",
    "from os import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "a24d1e28",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 包：将多个模块放入到同一个文件夹中\n",
    "# 导入：包.模块，调用模块中的方法：包.模块.方法\n",
    "# 导入包建议：from 包 import 模块，调用：模块.方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "b1557a74",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "b'<!DOCTYPE html><!--STATUS OK--><html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\"><meta content=\"always\" name=\"referrer\"><meta name=\"theme-color\" content=\"#ffffff\"><meta name=\"description\" content=\"\\xe5\\x85\\xa8\\xe7\\x90\\x83\\xe9\\xa2\\x86\\xe5\\x85\\x88\\xe7'\n"
     ]
    }
   ],
   "source": [
    "from urllib.request import urlopen\n",
    "\n",
    "with urlopen('http://www.baidu.com/') as f:\n",
    "    print(f.read(300))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "1c1060fd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['DirEntry',\n",
       " 'EX_OK',\n",
       " 'F_OK',\n",
       " 'GenericAlias',\n",
       " 'Mapping',\n",
       " 'MutableMapping',\n",
       " 'O_APPEND',\n",
       " 'O_BINARY',\n",
       " 'O_CREAT',\n",
       " 'O_EXCL',\n",
       " 'O_NOINHERIT',\n",
       " 'O_RANDOM',\n",
       " 'O_RDONLY',\n",
       " 'O_RDWR',\n",
       " 'O_SEQUENTIAL',\n",
       " 'O_SHORT_LIVED',\n",
       " 'O_TEMPORARY',\n",
       " 'O_TEXT',\n",
       " 'O_TRUNC',\n",
       " 'O_WRONLY',\n",
       " 'P_DETACH',\n",
       " 'P_NOWAIT',\n",
       " 'P_NOWAITO',\n",
       " 'P_OVERLAY',\n",
       " 'P_WAIT',\n",
       " 'PathLike',\n",
       " 'R_OK',\n",
       " 'SEEK_CUR',\n",
       " 'SEEK_END',\n",
       " 'SEEK_SET',\n",
       " 'TMP_MAX',\n",
       " 'W_OK',\n",
       " 'X_OK',\n",
       " '_AddedDllDirectory',\n",
       " '_Environ',\n",
       " '__all__',\n",
       " '__builtins__',\n",
       " '__doc__',\n",
       " '__file__',\n",
       " '__loader__',\n",
       " '__name__',\n",
       " '__package__',\n",
       " '__spec__',\n",
       " '_check_methods',\n",
       " '_execvpe',\n",
       " '_exists',\n",
       " '_exit',\n",
       " '_fspath',\n",
       " '_get_exports_list',\n",
       " '_walk',\n",
       " '_wrap_close',\n",
       " 'abc',\n",
       " 'abort',\n",
       " 'access',\n",
       " 'add_dll_directory',\n",
       " 'altsep',\n",
       " 'chdir',\n",
       " 'chmod',\n",
       " 'close',\n",
       " 'closerange',\n",
       " 'cpu_count',\n",
       " 'curdir',\n",
       " 'defpath',\n",
       " 'device_encoding',\n",
       " 'devnull',\n",
       " 'dup',\n",
       " 'dup2',\n",
       " 'environ',\n",
       " 'error',\n",
       " 'execl',\n",
       " 'execle',\n",
       " 'execlp',\n",
       " 'execlpe',\n",
       " 'execv',\n",
       " 'execve',\n",
       " 'execvp',\n",
       " 'execvpe',\n",
       " 'extsep',\n",
       " 'fdopen',\n",
       " 'fsdecode',\n",
       " 'fsencode',\n",
       " 'fspath',\n",
       " 'fstat',\n",
       " 'fsync',\n",
       " 'ftruncate',\n",
       " 'get_exec_path',\n",
       " 'get_handle_inheritable',\n",
       " 'get_inheritable',\n",
       " 'get_terminal_size',\n",
       " 'getcwd',\n",
       " 'getcwdb',\n",
       " 'getenv',\n",
       " 'getlogin',\n",
       " 'getpid',\n",
       " 'getppid',\n",
       " 'isatty',\n",
       " 'kill',\n",
       " 'linesep',\n",
       " 'link',\n",
       " 'listdir',\n",
       " 'lseek',\n",
       " 'lstat',\n",
       " 'makedirs',\n",
       " 'mkdir',\n",
       " 'name',\n",
       " 'open',\n",
       " 'pardir',\n",
       " 'path',\n",
       " 'pathsep',\n",
       " 'pipe',\n",
       " 'popen',\n",
       " 'putenv',\n",
       " 'read',\n",
       " 'readlink',\n",
       " 'remove',\n",
       " 'removedirs',\n",
       " 'rename',\n",
       " 'renames',\n",
       " 'replace',\n",
       " 'rmdir',\n",
       " 'scandir',\n",
       " 'sep',\n",
       " 'set_handle_inheritable',\n",
       " 'set_inheritable',\n",
       " 'spawnl',\n",
       " 'spawnle',\n",
       " 'spawnv',\n",
       " 'spawnve',\n",
       " 'st',\n",
       " 'startfile',\n",
       " 'stat',\n",
       " 'stat_result',\n",
       " 'statvfs_result',\n",
       " 'strerror',\n",
       " 'supports_bytes_environ',\n",
       " 'supports_dir_fd',\n",
       " 'supports_effective_ids',\n",
       " 'supports_fd',\n",
       " 'supports_follow_symlinks',\n",
       " 'symlink',\n",
       " 'sys',\n",
       " 'system',\n",
       " 'terminal_size',\n",
       " 'times',\n",
       " 'times_result',\n",
       " 'truncate',\n",
       " 'umask',\n",
       " 'uname_result',\n",
       " 'unlink',\n",
       " 'unsetenv',\n",
       " 'urandom',\n",
       " 'utime',\n",
       " 'waitpid',\n",
       " 'waitstatus_to_exitcode',\n",
       " 'walk',\n",
       " 'write']"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dir(os)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
